package com.web.util.sql;

public class IdUtil {
	
public static String process(String maxId, String prefix, int seed) {
		
		String strId = "";
		int intId = 0;		
		int exponent = 1;	
		
		if (maxId==null) {
			strId = String.valueOf(seed);
			strId = strId.substring(1, strId.length());
			strId = prefix + strId;
			return strId;
		}
		
		maxId = maxId.trim();
		
		exponent = maxId.length() - prefix.length();		
		
		strId = maxId.substring(prefix.length() + 1, maxId.length());
		intId = Integer.parseInt(strId) + 1 + seedFactor(exponent);		
		strId = String.valueOf(intId);
		strId = strId.substring(1, strId.length());
		strId = prefix + strId;
		
		return strId;
	}
	
	public static int seedFactor(int exponent) {
		
		int seed = 1;		
		for (int i=1; i<=exponent; i++) {
			seed *= 10;
		}		
		return seed;
	}

}
